<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
	<h:head>
		<title>#{msgs['search.title']}</title>
		<link
			href="#{facesContext.externalContext.requestContextPath}/css/styles.css"
			rel="stylesheet" type="text/css" />
	</h:head>
	<h:body>
		<p:ajaxStatus style="width:64px;height:64px;position:fixed;right:100px;top:100px">  
		    <f:facet name="start">  
		        <p:graphicImage value="/img/loading.gif" />  
		    </f:facet>  
		  
		    <f:facet name="complete">  
		        <h:outputText value="" />  
		    </f:facet>  
		</p:ajaxStatus>
		<div align="center" style="padding-top: 10px;">
			<h:form id="searchForm">
				<p:growl id="messages" showDetail="true" sticky="true"
					autoUpdate="true" life="1" />
				<p:panel header="#{msgs['search.title']}" styleClass="search">
					<div align="center">
						<p:panelGrid columns="2">
							<p:outputLabel value="#{msgs['search.search']}:" />
							<p:inputText value="#{searchBean.keyTerms}" />
						</p:panelGrid>
						<br />
						<p:commandButton value="#{msgs['search.search']}"
							update=":resultsForm:docsDataGrid" action="#{searchBean.search}" />
					</div>
				</p:panel>
				<p:dialog modal="true" widgetVar="statusDialog" header="Status"
					draggable="false" closable="false" resizable="false">
					<p:graphicImage value="/design/ajaxloadingbar.gif" />
				</p:dialog>
	
				<script type="text/javascript">
					function start() {
						PF('searchForm:statusDialog').show();
					}
	
					function stop() {
						PF('searchForm:statusDialog').hide();
					}
				</script>
				<p:separator/>
			</h:form>
			<h:form id="resultsForm">
				<p:dataGrid id="docsDataGrid" value="#{searchBean.docsList}"
					var="doc" itemStyle="height:100px;" columns="1" rows="6"
					paginator="true"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
					<p:commandLink id="view" ajax="false" style="color:blue;"
						action="#{searchBean.selectDoc}" oncomplete="PrimeFaces.monitorDownload(start, stop)">
						<h:outputText value="#{doc.nameDocument}" />
						<f:setPropertyActionListener value="#{doc}"
							target="#{searchBean.selectedDoc}" />
						<p:fileDownload value="#{searchBean.selectedDoc.file}" />
					</p:commandLink>
					<p:separator/>
				</p:dataGrid>
			</h:form>
		</div>
</h:body>
</html>